/*
 * CommProtocol.h
 *
 *  Created on: Jan 15, 2014
 *      Author: ppks
 */

#ifndef COMMPROTOCOL_H_
#define COMMPROTOCOL_H_

#include "avr/pgmspace.h"

/********************************************************************************/
/* Configuration                                                                */
/********************************************************************************/
#define MSP_VERSION         0


#define COMM_SERIAL         1
#define COMM_I2C            2
#define COMM_SPI            3

#define COMM_PROTOCOL                       COMM_SERIAL
    #define COMM_SERIAL_LISTEN_ALL_PORTS    1
    #define COMM_PROTOCOL_SERIAL_PORT       0

#define INPUT_BUFFER_SIZE   64

#define HEADER_START_BYTE   '$'
#define HEADER_SECOND_BYTE  'M'
#define HEADER_DATA_IN      '<'
#define HEADER_DATA_OUT     '>'
#define HEADER_DATA_ERROR   '!'

/********************************************************************************/
/* Exported Variables Declaration                                               */
/********************************************************************************/

/********************************************************************************/
/* Exported Functions Prototypes                                                */
/********************************************************************************/
void CommProtocol_Process(void);
void CommProtocol_SendBlock(uint8_t *data, uint8_t size);
void CommProtocol_ReadBlock(uint8_t *data, uint8_t size);
void CommProtocol_HeaderReply(uint8_t size);
void CommProtocol_AppendUint8(uint8_t data);
void CommProtocol_AppendUint16(uint16_t data);
void CommProtocol_AppendUint32(uint32_t data);
uint8_t CommProtocol_ReadUint8(void);
uint16_t CommProtocol_ReadUint16(void);
uint32_t CommProtocol_ReadUint32(void);
void CommProtocol_SendNames(PGM_P s);
#endif /* COMMPROTOCOL_H_ */
